<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>

<button onclick="downLoad()">下载</button>

<script type="text/javascript">
    function downLoad() {
        const xhr = new XMLHttpRequest()
        const POST_URL = `http://192.168.208.82.cdc.k8s:26117/Marketing_Gateway/newCustCount/marketingCountExport?dateStr=20211019` // 接口地址
        xhr.open('get', POST_URL, true)
        xhr.responseType = 'blob' // 返回类型blob
        xhr.setRequestHeader('token', 'eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJjZGNJZCIsImlhdCI6MTYzNDYzMzUyMiwic3ViIjoie1wiZW1wbG95ZWVOYW1lXCI6XCLotoXnuqfnrqHnkIblkZhcIixcIm9yZ05hbWVcIjpcIuWbm-W3neecgeaIkOmDveW4guWIhuihjFwiLFwicm9sZUlkXCI6XCI0MDI4NGNmZDc1NGYxZTExMDE3NTcyMmMwZTY5MDAwOCw0MDI4ZTI5MzU2Njk4M2JlMDE1NjY5ODUyZDNmMDAwMFwiLFwibW9iaWxlXCI6XCIxNzc4MDYzMDIyNVwiLFwidXNlck5hbWVcIjpcIui2hee6p-euoeeQhuWRmFwiLFwib3JnSWRcIjpcIjIySDgwMVwiLFwib3JnVHlwZVwiOlwiM1wiLFwiY29tcGFueUlkXCI6XCIyMkg5OTlcIixcInJvbGVDb2RlXCI6XCJTVVBFUl9NQU5BR0VSXCIsXCJvY3JtSWRcIjpcImZmODA4MDgxNTI4NjAzZDgwMTUyODYxMWI5NzUwMDA5XCIsXCJjbW1JZFwiOlwiMjJIODAxXCIsXCJ1c2VyUG9zaUlkXCI6XCI0MDI4ZTI4ZTViYThlNTM5MDE1YmE4ZjIxMTk5MDAxMFwiLFwiaWRcIjpcIjQwMjhlMjhlNWJhOGU1MzkwMTViYThmMjExNWYwMDBlXCIsXCJib2VpbmdJZFwiOlwiMjJIODAxXCIsXCJhY2NvdW50XCI6XCJhZG1pblwiLFwibmV3Um9sZUNvZGVcIjpcIlNVUEVSX01BTkFHRVIsUExBVEZPUk1fTUFOQUdFUlwifSIsImV4cCI6MTYzNDY2MzUyMn0.gX4St3JqHQ9NELkltmc8dIOXAz3py-j6D_mUFyPmlcw')
        xhr.onload = function() {
            if (this.status === 200) {
                const blob = new window.Blob([this.response], { type: 'application/octet-stream' })
                const reader = new FileReader()
                reader.readAsDataURL(blob) // 转换为base64，可以直接放入a标签href
                reader.onload = function() {
                    const a = document.createElement('a') // 转换完成，创建一个a标签用于下载
                    a.download = 'test.xlsx'
                    a.href = URL.createObjectURL(blob)
                    document.body.appendChild(a)
                    a.click()
                    document.body.removeChild(a)
                }
            }
        }
        const params = JSON.stringify({ tempType: 'SingleEconomyAdd' })  // 传参
        xhr.send(params)
    }

</script>
</body>
</html>